<template>
  <div>
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="业主姓名" placeholder="业主姓名">
        <el-input v-model="form.ownerName" />
      </el-form-item>
      <el-form-item label="房源类型">
        <el-select v-model="form.houseType" placeholder="请选择">
          <el-option label="国有房产" value="1" />
          <el-option label="直管房产" value="2" />
          <el-option label="自管房产" value="3" />
          <el-option label="军队房产" value="4" />
          <el-option label="集体所有房产" value="5" />
          <el-option label="有(自由)房产" value="6" />
          <el-option label="港、澳、台投资房产" value="7" />
          <el-option label="涉外房产" value="8" />
          <el-option label="其它房产)" value="9" />
        </el-select>
      </el-form-item>
      <el-form-item label="小区名称" placeholder="小区名称">
        <el-input v-model="form.premiseName" />
      </el-form-item>
      <el-form-item label="起租日期">
        <el-col :span="11">
          <el-date-picker v-model="form.leaseStartTime" type="date" placeholder="选择日期" style="width: 100%;" />
        </el-col>
        <el-col class="line" :span="2">至</el-col>
        <el-col :span="11">
          <el-date-picker v-model="form.leaseEndTime" type="date" placeholder="选择日期" style="width: 100%;" />
        </el-col>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">查询</el-button>
        <el-button type="primary" @click="qingkong">清空</el-button>
      </el-form-item>
    </el-form>
    <el-table
      :data="tableData"
      style="width: 100%"
    >
      <el-table-column
        prop="ownerName"
        label="业主姓名"
        width="180"
      />
      <el-table-column
        prop="sfContractNo"
        label="收房合同编号"
        width="180"
      />
      <el-table-column
        prop="ownerMobile"
        label="电话"
        width="180"
      />
      <el-table-column
        prop="premiseName"
        label="小区"
        width="180"
      />
      <el-table-column
        prop="leaseStartTime"
        label="起租时间"
        width="180"
      />
      <el-table-column
        prop="leaseEndTime"
        label="结束时间"
        width="180"
      />
      <el-table-column
        prop="address"
        label="押付方式"
      />
      <el-table-column
        prop="paymentType"
        label="押金"
      />
      <el-table-column
        prop="monthRent"
        label="租金"
      />
      <el-table-column
        prop="xyStatus"
        label="状态"
      >
        <template slot-scope="scope">
          {{ scope.row.xyStatus == 0?'未续约':'续约' }}
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      :current-page="pageNum"
      :page-sizes="[2, 3, 4, 5]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script>
export default {
  data() {
    return {
      // 列表
      tableData: [],
      // 分页
      pageNum: 1,
      pageSize: 5,
      total: 0,
      // 查询
      form: {
        ownerName: '',
        houseType: null,
        premiseName: null,
        leaseStartTime: null,
        leaseEndTime: null
      }
    }
  },
  created() {
    this.init()
  },
  methods: {
    // 列表
    init() {
      this.axios.get('http://localhost:9999/house-foreclosure/tSfContract/selects', {
        params: {
          pageNum: this.pageNum,
          pageSize: this.pageSize,
          ownerName: this.form.ownerName,
          houseType: this.form.houseType,
          premiseName: this.form.premiseName,
          leaseStartTime: this.form.leaseStartTime,
          leaseEndTime: this.form.leaseEndTime
        }
      }).then((response) => {
        // alert(response)
        console.log(response.data)
        this.tableData = response.data.obj.list
        this.total = response.data.obj.total
      })
    },
    // 分页
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`)
      this.pageSize = val
      this.init()
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`)
      this.pageNum = val
      this.init()
    },
    // 清空
    qingkong() {
      this.form = {}
    },
    onSubmit() {
      this.init()
    }
  }
}
</script>
<style scoped>

</style>
